<template>
	<view :style="themeColor">
		<view class="page">
			<view class="flex benben-position-layout flex flex-wrap align-center cardRedemption_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex flex-wrap align-center justify-between flex-sub cardRedemption_fd0_0'>
					<view class='flex flex-wrap align-center cardRedemption_fd0_0_c0' @tap.stop="handleJumpDiy"
						data-type="back" data-url="1">
						<text class='fu-iconfont2  cardRedemption_fd0_0_c0_c0'>&#xe794;</text>
					</view>
					<text class='cardRedemption_fd0_0_c1'>次卡兑换</text>
					<view class='flex flex-wrap align-center cardRedemption_fd0_0_c0'>
					</view>
				</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<!---flex布局flex布局开始-->
			<view class="flex benben-flex-layout flex-wrap align-center cardRedemption_flex_1">
				<image class='cardRedemption_fd1_0' mode="aspectFill" :src='banner_list[0].thumb'></image>
			</view>

			<!---flex布局flex布局结束-->
			<!---flex布局flex布局开始-->  
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout cardRedemption_flex_2">
				<text class='cardRedemption_fd2_0'>填写兑换码</text>
				<view class='flex flex-wrap align-center cardRedemption_fd2_1'>
					<text class='cardRedemption_fd2_1_c0'>兑换卡号</text>
					<benben-input class='flex-sub cardRedemption_fd2_1_c1' type="text" :placeholder="`请输入卡号`"
						confirm-type="done" :maxlength="-1" placeholder-style="color:#999;font-size:32rpx"
						v-model="code" />
				</view>
				<view class='flex flex-wrap align-center cardRedemption_fd2_1'>
					<text class='cardRedemption_fd2_2_c0'>卡 密 码</text>
					<benben-input class='flex-sub cardRedemption_fd2_1_c1' type="number" :placeholder="`请输入卡密码`"
						confirm-type="done" :maxlength="-1" :password='true'
						placeholder-style="color:#999;font-size:32rpx" v-model="password" />
				</view>
			</view>

			<!---flex布局flex布局结束-->
			<view class="flex flex-wrap align-start justify-center benben-position-layout flex cardRedemption_flex_3">
				<button class='cardRedemption_fd3_0' @tap.stop="postExchangeFunc()">兑换</button>

			</view>
			<view :style="{height: '120rpx'}"></view>


		</view>
	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'

	export default {
		components: {},


		data() {
			return {
				"code": "",
				"password": "",
				"banner_list": [],
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
		this.get_banner_listFunc()
		uni.showShareMenu({
			withShareTicket: true,
			//设置下方的Menus菜单，才能够让发送给朋友与分享到朋友圈两个按钮可以点击
			menus: ["shareAppMessage", "shareTimeline"]
		})
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onShareAppMessage() {
			return {
				title: '高整无忧-数字家政平台',
				path: `/pages/my/cardRedemption/cardRedemption`
			}
		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//获取图片
			async get_banner_listFunc() {
				clearInterval(this.intervalId);
				this.intervalId = null
				//请求方法
				//数据验证
			
				let databanner_list = await this.$api.get(global.apiUrls.post636e02b419726, {
					operationadstype_id: '16'
				});
			
				if (databanner_list.data.code != 1) {
					this.$message.info(databanner_list.data.msg);
					return
				}
				let infobanner_list = databanner_list.data;
				this.banner_list = infobanner_list.data
			
			},
			//提交兑换
			async postExchangeFunc() {
				if (!validate(this.code, 'require')) {
					this.$message.info('请输入兑换卡号');
					return false;
				}
				if (!validate(this.password, 'require')) {
					this.$message.info('请输入卡密');
					return false;
				}
				//请求方法
				//数据验证

				let data6544b42378213 = await this.$api.dbPost(global.apiUrls.post6544b42378213, {
					code: this.code,
					password: this.password
				});
				if (!data6544b42378213) return
				if (data6544b42378213.data.code != 1) {
					this.$message.info(data6544b42378213.data.msg);
					return
				}
				uni.showToast({
					title: '兑换成功',
					mask: true,
					icon: 'none',
					duration: 1500
				});
				setTimeout(() => {
					this.$urouter.navigateTo(`/pages/my/packageRecord/packageRecord`);
				}, 500)

			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: rgba(255, 255, 255, 1);
		background-size: 100% auto;
	}

	.cardRedemption_flex_0 {
		background: #fff;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.cardRedemption_fd0_0_c1 {
		font-size: 36rpx;
		font-weight: 500;
		color: #333;
	}

	.cardRedemption_fd0_0_c0_c0 {
		font-size: 36rpx;
		color: #333;
	}

	.cardRedemption_fd0_0_c0 {
		width: 120rpx;
		height: 88rpx;
	}

	.cardRedemption_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		height: 88rpx;
	}

	.cardRedemption_flex_1 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		margin: 20rpx 0rpx 0rpx 0rpx;
	}

	.cardRedemption_fd1_0 {
		width: 686rpx;
		height: 320rpx;
		border-radius: 16rpx;
	}

	.cardRedemption_flex_2 {
		padding: 0rpx 32rpx 0rpx 32rpx;
	}

	.cardRedemption_fd2_2_c0 {
		font-size: 32rpx;
		font-weight: 400;
		color: #333;
		margin: 0rpx 20rpx 0rpx 0rpx;
		line-height: 40rpx;
		white-space: pre-wrap;
	}

	.cardRedemption_fd2_1_c1 {
		font-size: 32rpx;
		font-weight: 400;
		color: #333;
	}

	.cardRedemption_fd2_1_c0 {
		font-size: 32rpx;
		font-weight: 400;
		color: #333;
		margin: 0rpx 20rpx 0rpx 0rpx;
		line-height: 40rpx;
	}

	.cardRedemption_fd2_1 {
		border-bottom: 1px solid #eee;
		padding: 32rpx 0rpx 32rpx 0rpx;
	}

	.cardRedemption_fd2_0 {
		font-size: 32rpx;
		font-weight: 700;
		color: #333;
		margin: 32rpx 0rpx 0rpx 0rpx;
	}

	.cardRedemption_flex_3 {
		width: 750rpx;
		height: 120rpx;
		overflow: hidden;
		z-index: 10;
		bottom: calc(0rpx + var(--window-bottom));
	}

	.cardRedemption_fd3_0 {
		background: var(--benbenbgColor2);
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		width: 686rpx;
		line-height: 80rpx;
		font-size: 32rpx;
		color: #fff;
		height: 80rpx;
	}
</style>